// [[ OnflowGenerator File UUID: defb5c38d1264483af293a0315fc092d  ]]
package com.itdct.onflow.system.component.controller

import com.itdct.onflow.core.type.*
import com.itdct.onflow.core.vo.KeyLabelValueVo
import com.itdct.onflow.core.vo.RespPageVo
import com.itdct.onflow.core.vo.RespVo
import com.itdct.onflow.system.common.base.BaseSysController
import com.itdct.onflow.system.component.qo.SysComponentEditQo
import com.itdct.onflow.system.component.qo.SysComponentSearchQo
import com.itdct.onflow.system.component.service.SysComponentService
import com.itdct.onflow.system.component.vo.SysComponentDetailVo
import com.itdct.onflow.system.component.vo.SysComponentListVo
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.http.MediaType
import org.springframework.validation.annotation.Validated
import org.springframework.web.bind.annotation.*

/**
 * @author DCTANT
 * @date 2025-09-15 16:13:06
 * @version 1.0
 * @description 系统组件接口控制
 */
@Tag(name = SysComponentController.moduleName)
@RestController
@RequestMapping(value = ["/sysComponent"], produces = [MediaType.APPLICATION_JSON_VALUE], method = [RequestMethod.POST])
class SysComponentController(
    val sysComponentService: SysComponentService
) : BaseSysController() {
    companion object {
        const val moduleName = "系统组件"
    }

    @Operation(summary = moduleName + "添加")
    @PostMapping("/add.adw")
    fun add(@RequestBody @Validated(Add::class) qo: SysComponentEditQo): RespVo<Long> {
        return sysComponentService.add(qo, getContext())
    }

    @Operation(summary = moduleName + "更新")
    @PostMapping("/update.adw")
    fun update(@RequestBody @Validated(Update::class) qo: SysComponentEditQo): RespVo<Unit> {
        return sysComponentService.update(qo, getContext())
    }

    @Operation(summary = moduleName + "删除")
    @PostMapping("/delete.adw")
    fun delete(@RequestBody @Validated(Delete::class) qo: SysComponentEditQo): RespVo<Unit> {
        return sysComponentService.delete(qo, getContext())
    }

    @Operation(summary = moduleName + "详情")
    @PostMapping("/detail.adw")
    fun detail(@RequestBody @Validated(Detail::class) qo: SysComponentSearchQo): RespVo<SysComponentDetailVo> {
        return sysComponentService.detail(qo, getContext())
    }

    @Operation(summary = moduleName + "列表")
    @PostMapping("/page.adw")
    fun page(@RequestBody @Validated(Page::class) qo: SysComponentSearchQo): RespPageVo<SysComponentListVo> {
        return sysComponentService.page(qo, getContext())
    }

    @Operation(summary = moduleName + "获取按菜单ID的组件列表")
    @PostMapping("/getByMenuId.adw")
    fun getByMenuId(@RequestBody qo: SysComponentSearchQo): RespVo<List<KeyLabelValueVo>> {
        return sysComponentService.getByMenuId(qo, getContext())
    }

// [[ OnflowGenerator Range (- selectFunctions -) Start ]]

    @Operation(summary = moduleName + "组件标题下拉选")
    @PostMapping("/selectTitleList.adw")
    fun selectTitleList(@RequestBody qo: SysComponentSearchQo): RespVo<List<KeyLabelValueVo>> {
        return sysComponentService.selectTitleList(qo, getContext())
    }
// [[ OnflowGenerator Range (- selectFunctions -) End ]]
}